<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<c:set var="contestPath" value="<%=request.getContextPath()%>"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
	<head>
		<title>用户列表</title>
		<script src="${pageContext.request.contextPath}/static/lib/ajaxfileupload.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function(){
				$('.check').click(function(){
					var id = $(this).val();
					if(confirm('是否确认删除？')){
						window.location.href='delete/'+id;
					}else{
						return;
					}
				});

				$('#uploadFile').ace_file_input({
					style:'well',
					btn_choose:'Drop files here or click to choose',
					btn_change:null,
					no_icon:'ace-icon fa fa-cloud-upload',
					droppable:true,
					thumbnail:'samll',
					preview_error: function(filename, eroor_code) {
					}
				}).on('change', function(){
//					consloe.log($(this).data('ace_input_files'));
//					consloe.log($(this).data('ace_input_method'));
				});

				$('#batchAddStudentBtn').click(function(){
					$('#uploadFileModal').modal('show');
				});

				$('#subjectStudentSaveBtn').on('click', function(){
					$.ajaxFileUpload({
						url: '${contestPath}/teacher/uploadFile',
						secureuri: false,
						fileElementId: 'uploadFile',
						dataType: 'json',
						complete: function(data){
							//alert(data);
						},
						success: function (data, status) {
 							if(data.success ) {
								alert('成功');
								window.location.reload();
							}else {
								alert(data.messageMap.message);
							}
						},
						error: function(data, status, e){
							alert(e);
						}
					});
				});
			});
		</script>
	</head>

	<body>
		<div id="messageDiv">
			<c:if test="${not empty message }">
				<script type="text/javascript">
					alert("${message}");
				</script>
			</c:if>
		</div>

		<!-- /section:settings.box -->
		<div class="page-content-area">
			<div class="page-header">
				<a href="userChangeLocale?localeType=en_US"><button type="button" class="btn btn-xs btn-default"><spring:message code="page.user.index.english"/></button></a>
				<a href="userChangeLocale?localeType=zh_CN"><button type="button" class="btn btn-xs btn-default"><spring:message code="page.user.index.chinese"/></button></a>
			</div><!-- /.page-header -->

			<!-- 上传-模态框（Modal） -->
			<div class="modal fade" id="uploadFileModal" tabindex="-1" role="dialog" aria-labelledby="uploadFileModalLabel" aria-hidden="true">
			    <div class="modal-dialog">
			        <div class="modal-content">
			            <div class="modal-header">
			                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			                <h4 class="modal-title" id="uploadFileModalLabel"><spring:message code="user.upload.message"/></h4>
			            </div>
			            <div class="modal-body">
			            	<input id="uploadFile" name="uploadFile" type="file">
						</div>
			            <div class="modal-footer">
			                <button type="button" class="btn btn-default" data-dismiss="modal"><spring:message code="user.close.message"/></button>
			                <button id="subjectStudentSaveBtn" type="button" class="btn btn-primary"><spring:message code="user.preservation.message"/></button>
			            </div>
			        </div><!-- /.modal-content -->
			    </div><!-- /.modal -->
			</div>

			<div class="row">
				<div class="col-xs-12">
					<!-- PAGE CONTENT BEGINS -->
					<div class="row">
						<div class="col-xs-12">
							<button type="button" class="btn btn-xs btn-success" onclick="window.location.href='add'">
                               	<i class="ace-icon fa fa-plus bigger-120"></i><spring:message code="user.add.message"/>
                               </button>
                               <button id="batchAddStudentBtn" type="button" class="btn btn-xs btn-success">
                               	<i class="ace-icon fa fa-plus bigger-120"></i><spring:message code="user.batchAdd.message"/>
                               </button>
							<table id="sample-table-1" class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
										<th class="center">
											<label class="position-relative">
												<input type="checkbox" class="ace" />
												<span class="lbl"></span>
											</label>
										</th>
                                                 <th><spring:message code="user.id.message"/></th>
									    <th><spring:message code="user.name.message"/></th>
									    <th><spring:message code="user.gender.message"/></th>
									    <th><spring:message code="user.birthday.message"/></th>
									    <th><spring:message code="user.tel.message"/></th>
									    <th><spring:message code="user.address.message"/></th>
									    <th><spring:message code="user.action.message"/></th>
                                         	</tr>
                                         	
								</thead>

								<tbody>
                                         <c:forEach items="${userList }" var="user">
                                             <tr>
                                                     <td class="center">
                                                         <label class="position-relative">
                                                             <input type="checkbox" class="ace" />
                                                             <span class="lbl"></span>
                                                         </label>
                                                     </td>
                                                     <td>${user.userId }</td>
                                                     <td>${user.userName }</td>
                                                     <td>${user.gender }</td>
                                                     <td>${user.birthday }</td>
                                                     <td>${user.tel }</td>
                                                     <td>${user.address }</td>
										<td>
											<button class="btn btn-xs btn-info" onclick="window.location.href='edit/${user.userId }'">
												<i class="ace-icon fa fa-pencil bigger-120"></i>
											</button>

											<button class="btn btn-xs btn-danger check" value="${user.userId }">
												<i class="ace-icon fa fa-trash-o bigger-120"></i>
											</button>
										</td>
									</tr>
								</c:forEach>
								</tbody>
							</table>
						</div><!-- /.span -->
					</div><!-- /.row -->

					<div class="hr hr-18 dotted hr-double"></div>
				</div><!-- /.col -->
			</div><!-- /.row -->
		</div><!-- /.page-content-area -->
	</body>
</html>
